package cn.christ.com.mobilesafe.view.activity_sjfd;

import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;

import butterknife.BindView;
import butterknife.OnClick;
import cn.christ.com.mobilesafe.R;
import cn.christ.com.mobilesafe.common.Global;
import cn.christ.com.mobilesafe.common.utils.SPUtils;
import cn.christ.com.mobilesafe.constant.Constants;

/**
 * Created by Administrator on 2018/7/22.
 */

public class SetingUpActivity5 extends BaseSetingUpActivity {
    @BindView(R.id.cb_step5)
    CheckBox cbStep5;
    @BindView(R.id.btn_next)
    Button btnNext;
    @BindView(R.id.btn_pre)
    Button btnPre;

    @Override
    public int getLayoutRes() {
        return R.layout.activity_setup5;
    }

    @Override
    public void initView() {
        boolean open = (boolean) SPUtils.get(Constants.SJFD_OPEN, false);
        cbStep5.setChecked(open);

    }


    @OnClick({R.id.cb_step5, R.id.btn_next, R.id.btn_pre})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.cb_step5:
                break;
            case R.id.btn_next:
                if (!cbStep5.isChecked()) {
                    Global.showToast("请设置防盗保护");
                    SPUtils.put(Constants.SJFD_OPEN, false);
                    return;
                }
                performNext();
                overridePendingTransition(R.anim.next_enter, R.anim.next_exit);
                break;
            case R.id.btn_pre:
                performPre();
                finish();
                overridePendingTransition(R.anim.pre_enter, R.anim.pre_exit);
                break;
        }
    }

    @Override
    public void initListener() {

    }

    @Override
    public void initData() {

    }

    @Override
    protected void next() {
        if (!cbStep5.isChecked()) {
            Global.showToast("请设置防盗保护");
            SPUtils.put(Constants.SJFD_OPEN, false);
            return;
        }
        SPUtils.put(Constants.SJFD_OPEN, true);
        startActivity(LostFindActivity.class);
    }

    @Override
    protected void performPre() {
        startActivity(SetingUpActivity4.class);
    }

    @Override
    protected void performNext() {
        SPUtils.put(Constants.SJFD_OPEN, true);
        startActivity(LostFindActivity.class);
    }


}
